<script setup lang="ts">
import { ref } from "vue";
import { onLoad, onPageScroll } from "@dcloudio/uni-app";
import { getAgreement } from "@/api/index";

const type = ref<'privacy' | 'user'>("user");
const title = ref("");
const content = ref("");

onLoad(async(option)=>{
  if(option?.type){
    type.value = option.type;
  }
  const data = await getAgreement({type: type.value});
  uni.setNavigationBarTitle({ title:data.title });
  title.value = data.title;
  content.value = data.content;
})

// 吸顶变色
const isScrolled = ref(false);
onPageScroll((e)=>{
  isScrolled.value = e.scrollTop > 0;
});
</script>

<template>
  <view class="relative overflow-hidden">
    <page-navbar :title="title" :isScrolled="isScrolled"></page-navbar>
    <view class="m-4 bg-white p-4 rounded-lg text-sm" v-html="content"></view>
  </view>
</template>
